﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>我的流程</title>
    <link href="Scripts/bootstrap/css/bootstrap.css" rel="stylesheet" type="text/css" />

    <link href="Scripts/bootstrap/css/font-awesome.css" rel="stylesheet" />
    <link href="Style/skin/css/style.css" rel="stylesheet" type="text/css" />
    <link href="./Scripts/bootstrap/css/style.min.css" rel="stylesheet" type="text/css"
          media="all" />
    <link href="Style/skin/css/animate.css" rel="stylesheet" type="text/css" />
    <script type="text/javascript" src="./Scripts/bootstrap/js/jquery.min.js"></script>
    <script type="text/javascript" src="./Scripts/bootstrap/js/bootstrap.min.js"></script>
    <script src="./Scripts/QueryString.js" type="text/javascript"></script>
    <script src="./Scripts/config.js" type="text/javascript"></script>
    <script src="./Comm/Gener.js" type="text/javascript"></script>
    <script src="Scripts/layui/layui/lay/modules/layer.js" type="text/javascript"></script>
    <script language="javascript" type="text/javascript">
        function WinOpenIt(url) {
            window.open(url);
            return;

            layer.open({
                skin: 'layer-class',
                type: 2,
                title: flow.Name,
                area: ['96%', '90%'],
                content: url
            });
        }

        /* ESC Key Down */
        function Esc() {
            if (event.keyCode == 27)
                window.close();
            return true;
        }

        var webUser = new WebUser();
        var flowNo = null;

        //页面启动函数.
        $(function () {
            flowNo = GetQueryString("FK_Flow");
            //  var flow = new Entity("BP.WF.Flow", flowNo);
            // $("#SearchLab").html(flow.Name);
            InitPage();
        });
        function InitPage() {

            var searchKey = $("#TB_Key").val();

            var gwfs = new Entities("BP.WF.GenerWorkFlows");
            var data = gwfs.DoMethodReturnString("QueryByLike", flowNo, searchKey);
            if (data.indexOf("err@") != -1) {
                alert(data);
                return;
            }
            gwfs = JSON.parse(data);

            var timeKey = "";


            var html = '';
            $('#Table1').html("");
            //增加处理.
            var idx = 0;
            for (var i = 0; i < gwfs.length; i++) {


                var gwf = gwfs[i];

                if (gwf.Emps.indexOf(webUser.No) == -1)
                    continue;

                idx++;

                var paras = gwf.AtPara; //参数.
                if (paras != '' && paras != null) {
                    paras = paras.replace("'", "\\'");
                    paras = paras.replace('@', '&');
                    paras = paras.replace('@', '&');
                    paras = paras.replace('@', '&');
                    paras = paras.replace('@', '&');
                    paras = paras.replace('@', '&');
                    paras = "1" + paras;
                }

                html = "<tr ><td class=Idx >" + idx + "</td>";

                var urlOpen = "MyView.htm?FK_Flow=" + flowNo + "&FID=0&WorkID=" + gwf.WorkID + "&IsRead=0&Paras=" + paras + "&T=" + timeKey;
                if (gwf.WFState != 3 && gwf.TodoEmps.indexOf(webUser.No) >= 0) {
                    urlOpen = "MyFlow.htm?FK_Flow=" + flowNo + "&FID=0&WorkID=" + gwf.WorkID + "&IsRead=0&Paras=" + paras + "&T=" + timeKey;
                }

                html += "<td>" + "<a href=\"javascript:WinOpenIt('" + urlOpen + "');\" ><img src='./Img/Mail_UnRead.png' border=0 />" + gwf.Title + "</a></td>";

                html += "<td>" + gwf.StarterName + "</td>";
                html += "<td>" + gwf.RDT + "</td>";
                html += "<td>" + gwf.NodeName + "</td>";
                html += "<td>" + gwf.TodoEmps + "</td>";
                html += "<td>" + gwf.SDTOfNode + "</td>";
                html += "<td>" + gwf.WFStateText + "</td>";

                html += "<td>";
                html += "<a href=\"javascript:Delete('" + flowNo + "'," + gwf.FK_Node + ",'" + gwf.WorkID + "')\">删除</a>";
                html += "</td>";
                html += "</tr>";

                $('#Table1').append(html);
            }
        }


        function Search() {
            InitPage();
        }

        function Start() {
            var url = "MyFlow.htm?FK_Flow=" + GetQueryString("FK_Flow");
            window.open(url);
        }
        //物理删除流程
        function Delete(flowNo, fkNode, workid) {

            if (window.confirm('您确定要删除吗？') == false)
                return;

            var handler = new HttpHandler("BP.WF.HttpHandler.WF_MyFlow");
            handler.AddPara("FK_Flow", flowNo);
            handler.AddPara("FK_Node", fkNode);
            handler.AddPara("WorkID", workid);
            handler.DoMethodReturnString("DeleteFlow");
            window.location.href = window.location.href;
        }

        /**/</script>

</head>
<body>
    <table class="table table-striped">
        <caption>
            <div id="SearchLab"></div>
            <label>
                <input type="text" id="TB_Key" name="TB_Key" class="form-control" style="width:200px" />
                <a href="#" class="btn btn-default btn-sm" id="Btn_Search" name="Btn_Search" onclick="Search()">查询</a>
                <a href="#" class="btn btn-default btn-sm" id="Btn_Start" name="Btn_Start" onclick="Start()">发起</a>
            </label>
            <!--<input type="button" id="Btn_Group" name="Btn_Group" value="分析" />-->
        </caption>
        <thead id="Table2">
            <tr>
                <th>
                    #
                </th>
                <th>
                    标题
                </th>
                <th width='60'>
                    发起人
                </th>
                <th width="140">
                    发起日期
                </th>
                <th>
                    停留节点
                </th>
                <th>
                    审批人
                </th>
                <th width='120'>
                    应完成日期
                </th>
                <th width='60'>
                    状态
                </th>
                <th width='60'>
                    操作
                </th>
            </tr>
        </thead>
        <tbody id="Table1">
        </tbody>
    </table>
</body>
</html>
